!function($) {
  $(function() {

		// -----------------------------------------------------------------------------------
		// JCarousel auf der Startseite einbinden
    $('#carousel').jcarousel({
			auto: 5,
			scroll: 1,
			wrap: 'last',
			buttonNextHTML: null,
			buttonPrevHTML: null,			
			initCallback: function(carousel) {
				$('.jcarousel-control a').bind('click', function() {
					carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
					return false;
				});

				// Disable autoscrolling if the user clicks the prev or next button.
				carousel.buttonNext.bind('click', function() {
					carousel.startAuto(0);
				});

				carousel.buttonPrev.bind('click', function() {
					carousel.startAuto(0);
				});

				// Pause autoscrolling if the user moves with the cursor over the clip.
				carousel.clip.hover(function() {
					carousel.stopAuto();
				}, function() {
					carousel.startAuto();
				});
			},
			itemVisibleInCallback: function(carousel, item, i) {
				$('.jcarousel-control a').removeClass('active');
				$('.jcarousel-control li:nth-child(' + i + ') a').addClass('active');
			}
    });

		// -----------------------------------------------------------------------------------
		// Fancybox fuer die Bildergalerie einbinden
		$('a[rel="fancybox[joomgallery]"]').fancybox({
			type: 'image',
			helpers:  {
				title:  null
			}			
		});
	});
}(window.jQuery);